package datas;

import java.text.DateFormat;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;

public class Data14
{
	
	public static void main(String[] args)
	{
		Date x = new Date();
		DateFormat df = DateFormat.getInstance();
		System.out.println(df.format(x));
		System.out.println("\na\n");
		a();
		System.out.println("\nb\n");
		b();
		
		System.out.println("\nparse");
		Date dt = new Date();
		System.out.println(dt);
		DateFormat dff = DateFormat.getDateInstance(DateFormat.SHORT);
		
		String s = dff.format(dt);
		
		try
		{
			Date dtt = dff.parse(s);
			System.out.println(dtt);
		} catch (ParseException e)
		{
			// TODO: handle exception
		}
		
	}
	
	public static void a()
	{
		Date date = new Date();
		Calendar c = Calendar.getInstance();
		c.add(Calendar.YEAR, 1);
		date = c.getTime();
		DateFormat df = DateFormat.getInstance();
		System.out.println(df.format(date));
	}
	
	public static void b()
	{
		Date d = new Date();
		DateFormat[] dfs = new DateFormat[6];
		dfs[0] = DateFormat.getInstance();
		dfs[1] = DateFormat.getDateInstance();
		dfs[2] = DateFormat.getDateInstance(DateFormat.SHORT);
		dfs[3] = DateFormat.getDateInstance(DateFormat.MEDIUM);
		dfs[4] = DateFormat.getDateInstance(DateFormat.LONG);
		dfs[5] = DateFormat.getDateInstance(DateFormat.FULL);
		
		for (DateFormat dateFormat : dfs)
		{
			System.out.println(dateFormat.format(d));
		}
	}

}
